//JScript File
// This js must include cookie_functions.js 


var sessionIDField = "IDSession";
var userNameField = "UserName";
var loginFlagField = "LoginFlag";

var cookieExpiresTime = 3600;


function GetUserNameFromCookie()
{
    if ( GetFlagFromCookie() != "1" )
        return null;
    else
        return GetCookie( userNameField );
}

function GetUserSessionIDFromCookie()
{
    if ( GetFlagFromCookie() != "1" )
        return null;
    else
        return GetCookie( sessionIDField );
}

function GetFlagFromCookie()
{
    loginFlag = GetCookie( loginFlagField );
    return loginFlag;
}

function SetUserNameToCookie( userName )
{
    SetCookie( userNameField, userName, cookieExpiresTime, '/', GetDomain() );
}

function SetUserSessionIDToCookie( sessionID )
{
    SetCookie( sessionIDField, sessionID, cookieExpiresTime, '/', GetDomain() );
}


function DifferCookieExpiresTime()
{
    var name = GetUserNameFromCookie();
    var sid = GetUserSessionIDFromCookie();
    if ( name != null && sid != null )
    {
	    SetUserNameToCookie( name );
	    SetUserSessionIDToCookie( sid );
	}
}

function DelUserInfoInCookie()
{
    DelCookie( userNameField );
    DelCookie( sessionIDField );   
}

function GetDomain()
{
    var host = window.location.hostname;
    var index = host.indexOf( "mytino" );
    
    return "." + host.substr( index );
}